package com.ruoyi.job;


import com.ruoyi.domain.T04;
import com.ruoyi.domain.T11;
import com.ruoyi.service.IT04Service;
import com.ruoyi.service.IT07Service;
import com.ruoyi.service.IT11Service;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import org.springframework.util.ObjectUtils;

import java.util.List;

import static com.ruoyi.framework.datasource.DynamicDataSourceContextHolder.log;


@Component
public class ScheduledService {
    @Autowired
    private IT07Service t07Service;
    @Autowired
    private IT11Service t11Service;
    @Autowired
    private IT04Service t04Service;

    //定时任务 将每天的使用量插入到表里面去
   @Scheduled(cron = "0 0 0 * * ?")
    public void scheduledDaily() {
        log.info("=====>>>>>每天00:00:00执行定时任务1  {}", System.currentTimeMillis());
         List<T11> list = t07Service.selectYesterDay();
         if(!ObjectUtils.isEmpty(list)){
             for (T11 t11 : list){
                 t11Service.insertT11(t11);
             }
         }
    }
    @Scheduled(cron = "0 0 0 * * ?")
    public void schedule1() {
       log.info("=====>>>>>每天00:00:00执行定时任务1  {}", System.currentTimeMillis());
       List<T04> list = t07Service.selectAllBefore();
       if(!ObjectUtils.isEmpty(list)){
           for (T04 t04 : list){
               t04Service.insertT04(t04);
           }
       }
    }
}
